package cgl.narada.service;

import java.util.Enumeration;
import java.util.Properties;
/**
 * This maintains the list of global service properties within multiple (or single)
 * entity instances in a JVM. 
 * 
 * @author Shrideep Pallickara
 * $Date
 * $Revision
 */
public class GlobalServiceProperties {

	Properties globalProperties;
	
	protected GlobalServiceProperties() {
		globalProperties = new Properties();
	}
	
	/** Gets a list of global property names registered with the global service 
	 * properties.
	 * @return
	 */
	public Enumeration getPropertyNames() {
		return globalProperties.propertyNames();
	}
	
	/**
	 * Adds a property to the global property list.
	 * @param property The key to be placed into this property list.
	 * @param value  the value corresponding to key.
	 */
	protected void addProperty(String property, String value) {
		globalProperties.setProperty(property, value);
	}
	
	
	/** 
	 * Checks to see if a given property exists.
	 * @param propertyName The property name being checked for. 
	 * @return true if it exists, false otherwise.
	 */
	public boolean hasProperty(String propertyName) {
		if (globalProperties.containsKey(propertyName)) {
			return true;
		}
		return false;
	}
	
	
	/**
	 * Retrieve a certain property's value.
	 * @param propertyName The property being retrieved.
	 * @return the value of the property OR NULL if it is NOT present.
	 */
	public String getProperty(String propertyName) {
		return globalProperties.getProperty(propertyName);
	}
}
